package GUitest;

import javax.swing.*;
import java.awt.*;

public class Background {
    public static void main(String[] args) {
        new Background();
    }

    public Background(){
        JFrame frame = new JFrame("测试背景");
        JPanel panel;
        ImageIcon bg = new ImageIcon("GUI\\images\\2.jpg");
        bg.setImage(bg.getImage().getScaledInstance(400, 300, Image.SCALE_DEFAULT));
        JLabel lbl = new JLabel(bg);
        lbl.setSize(400, 300);
        panel = (JPanel) frame.getContentPane();
        panel.setOpaque(false);
        panel.setLayout(new FlowLayout());
        panel.add(new JTextField(10));
        panel.add(new JButton("确定"));
        frame.getLayeredPane().setLayout(null);
        frame.getLayeredPane().add(lbl, Integer.valueOf((Integer.MIN_VALUE)));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        frame.setResizable(false);
        frame.setVisible(true);
    }
}
